<?php
namespace app\model;

use core\Factory;

class User extends \core\Model
{
    public function find($id, $field = [])
    {
        if (!empty($field) && is_array($field)) {
            $field = implode(', ', $field);
        } else {
            $field = '*';
        }

        return Factory::getDatabase()->query(
            "select {$field} from user where id ={$id} limit 1"
        )->fetch_assoc();
    }

    public function create($user)
    {
        //insert to database
        $userid = 1;
        $this->notify($user);
        return $userid;
    }
}